#!/usr/bin/env python
# coding=utf-8
"""
# @Created on : 2016/05/04 21:23
# @Author     : ldf (ldf@eehello.com)
# @Link       : http://www.eehello.com
# @Version    : 
# 本程序在python2.7下测试通过
"""

import threading
import time

def producer():
    print u'chef:等人来买包子.....'
    event.wait()
    event.clear()

    print u'chef: sb is coming for baozi....'

    print 'chef:making a baozi for sb....'
    time.sleep(5)

    #print event.set()

    print u'chef:你的包子好了'
    event.set()


def consumer():
    print u'chenchao:去买包子'
    print event.set()

    time.sleep(2)
    print 'chenchao:waiting for to be ready'
    while 1:
        if event.isSet():
            print u'Thanks....'
            break
        else:
            print u'还尼玛没好啊...'
            time.sleep(1)

event = threading.Event()

p = threading.Thread(target= producer)
c = threading.Thread(target= consumer)

p.start()
c.start()